﻿#region Using Statements
using System;
using Microsoft.Xna.Framework;
#endregion

namespace StarFox.ScreenComponents
{
    /// <summary>
    /// Contains commonly used helper functions.
    /// </summary>
    public class StarFoxHelper
    {
        static Random rnd = new Random((int)DateTime.Now.Ticks);

        /// <summary>
        /// Generates a random integer.
        /// </summary>
        /// <param name="max">Maximum value.</param>
        /// <returns></returns>
        public static int RandomInt(int max)
        {
            return rnd.Next(max);
        }

        /// <summary>
        /// Generates a random float.
        /// </summary>
        /// <param name="min">Minimum value.</param>
        /// <param name="max">Maximum value.</param>
        /// <returns></returns>
        public static float RandomFloat(float min, float max)
        {
            return (float)rnd.NextDouble() * (max - min) + min;
        }

        /// <summary>
        /// Generates a random vector.
        /// </summary>
        /// <param name="min">Minimum value.</param>
        /// <param name="max">Maximum value.</param>
        /// <returns></returns>
        public static Vector3 RandomVector(float min, float max)
        {
            return new Vector3(RandomFloat(min, max),
                               RandomFloat(min, max),
                               RandomFloat(min, max));
        }

        /// <summary>
        /// Calculates the angle between two normal vectors.
        /// </summary>
        /// <param name="v1">Source vector.</param>
        /// <param name="v2">Source vector.</param>
        /// <returns>The angle between the two vectors.</returns>
        public static float AngleBetweenVectors(Vector3 v1, Vector3 v2)
        {
            return (float)Math.Acos(Vector3.Dot(v1, v2));
        }
    }
}
